package com.zt.dev.simulationModel.service.impl;

import com.zt.dev.semiPhysicalEquipment.util.PageBean;
import com.zt.dev.simulationModel.mapper.Number_Simulation_Mapper;
import com.zt.dev.simulationModel.service.Number_Simulation_Service;
import com.zt.dev.simulationModel.vo.Number_Simulation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 卜德凯
 * @date 2020/2/11 15:01
 */
@Service
public class Number_Simulation_ServiceImpl implements Number_Simulation_Service {

    @Autowired
    private Number_Simulation_Mapper simulationMapper;

    /**
     * 获取所有的装备模型数据
     * @return
     */
    @Override
    public List<Number_Simulation> findModelList() {
        return simulationMapper.findModelList();
    }

    /**
     * 根据id查看模型详情
     * @param id
     * @return
     */
    @Override
    public List<Number_Simulation> findModelDetailsById(Integer id) {
        return simulationMapper.findModelDetailsById(id);
    }

    /**
     * 删除模型
     * @param id
     * @return
     */
    @Override
    public Integer deleteModel(Integer id) {
        return simulationMapper.deleteModel(id);
    }

    /**
     * 根据id修改模型
     * @param numberSimulation
     * @return
     */
    @Override
    public Integer updateModelById(Number_Simulation numberSimulation) {
        return simulationMapper.updateModelById(numberSimulation);
    }

    /**
     * 保存模型
     * @param numberSimulation
     * @return
     */
    @Override
    public Integer insertModel(Number_Simulation numberSimulation) {
        return simulationMapper.insertModel(numberSimulation);
    }

    /**
     * 根据id获取要复制模型的信息
     * @param id
     * @return
     */
    @Override
    public Number_Simulation findModelById(Integer id) {
        return simulationMapper.findModelById(id);
    }

    /**
     * 把获取到的模型数据擦插入表中
     * @param numberSimulation
     * @return
     */
    @Override
    public Integer copyModelById(Number_Simulation numberSimulation) {
        return simulationMapper.copyModelById(numberSimulation);
    }

    /**
     * 分页查看装备模型
     * @param currentPage
     * @param pageSize
     * @return
     */
    @Override
    public PageBean<Number_Simulation> pagingFindModel(int currentPage, int pageSize) {
        //获得总数
        int count = simulationMapper.getCount();
        PageBean pageBean = PageBean.pageCommon(count, currentPage, pageSize);
        //起始 结束 页
        int start = (currentPage-1)*pageBean.getPageSize();
        int end = pageBean.getPageSize();
        //封装每页显示的数据
        List<Number_Simulation> lists = simulationMapper.pagingFindModel(start,end);
        pageBean.setLists(lists);
        return pageBean;
    }
}
